package cn.echoedu.service;

import java.sql.SQLException;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.echoedu.control.FeedBackControl;
import cn.echoedu.control.LoginControl;
import cn.echoedu.control.RegisterControl;
import cn.echoedu.entity.receivecommand.ClassListReceive;
import cn.echoedu.entity.receivecommand.ClassNotifyFirstReceive;
import cn.echoedu.entity.receivecommand.ClassNotifyListDetailReceive;
import cn.echoedu.entity.receivecommand.ClassNotifyListReceive;
import cn.echoedu.entity.receivecommand.ContactsListReceive;
import cn.echoedu.entity.receivecommand.DeleteClassNotifyReceive;
import cn.echoedu.entity.receivecommand.DeleteSchoolNotifyReceive;
import cn.echoedu.entity.receivecommand.DepartmentListReceive;
import cn.echoedu.entity.receivecommand.FeedBackReceive;
import cn.echoedu.entity.receivecommand.IndexPicQueryReceive;
import cn.echoedu.entity.receivecommand.LoginReceive;
import cn.echoedu.entity.receivecommand.MonitorAddNotifyReceive;
import cn.echoedu.entity.receivecommand.ProfessionalListReceive;
import cn.echoedu.entity.receivecommand.QueryContactsListReceive;
import cn.echoedu.entity.receivecommand.QuerySchoolCalendarReceive;
import cn.echoedu.entity.receivecommand.QuerySchoolInfoByUserNumberReceive;
import cn.echoedu.entity.receivecommand.RegisterReceive;
import cn.echoedu.entity.receivecommand.SchoolListReceive;
import cn.echoedu.entity.receivecommand.SchoolNotifyFirstReceive;
import cn.echoedu.entity.receivecommand.SchoolNotifyListDetailReceive;
import cn.echoedu.entity.receivecommand.SchoolNotifyListReceive;
import cn.echoedu.entity.receivecommand.StudentListReceive;
import cn.echoedu.entity.receivecommand.TeacherAddNotifyReceive;
import cn.echoedu.entity.receivecommand.UpdateHeadImageReceive;
import cn.echoedu.entity.receivecommand.UpdateUserBaiDuReceive;
import cn.echoedu.entity.receivecommand.UpdateUserBirthdayReceive;
import cn.echoedu.entity.receivecommand.UpdateUserClassNameReceive;
import cn.echoedu.entity.receivecommand.UpdateUserDegressReceive;
import cn.echoedu.entity.receivecommand.UpdateUserEntranceTimeReceive;
import cn.echoedu.entity.receivecommand.UpdateUserJobReceive;
import cn.echoedu.entity.receivecommand.UpdateUserNameReceive;
import cn.echoedu.entity.receivecommand.UpdateUserPasswordReceive;
import cn.echoedu.entity.receivecommand.UpdateUserPoliticalStatusReceive;
import cn.echoedu.entity.receivecommand.UpdateUserQQReceive;
import cn.echoedu.entity.receivecommand.UpdateUserRealNameReceive;
import cn.echoedu.entity.receivecommand.UpdateUserSexReceive;
import cn.echoedu.entity.receivecommand.UpdateUserSinaReceive;
import cn.echoedu.entity.receivecommand.UpdateUserWechatReceive;
import cn.echoedu.util.L;

import com.google.gson.Gson;
import com.google.gson.JsonElement;

public class ReceiveService extends BaseService{
	private final String T="ReceiveService-------->";
	private HttpServlet httpservlet;
    
	public void doContactList(HttpServletRequest request,HttpServletResponse response
			,JsonElement je)throws SQLException {
		// TODO Auto-generated method stub
		 ContactsListReceive contactlistrec =new Gson().fromJson(je,
				 ContactsListReceive.class);
	    getTelContactsControl().doHotContactsList(request,response,contactlistrec
	    		,getTelContactsControl().CONTACTS_LIST);
}

	public void doContactsMakeFriend(HttpServletRequest request,HttpServletResponse
			response,JsonElement je) throws SQLException {
		// TODO Auto-generated method stub
		 ContactsListReceive contactlistrec =new Gson().fromJson(je,
				 ContactsListReceive.class);
	        getTelContactsControl().doHotContactsList(request,response,
	        		contactlistrec,getTelContactsControl().CONTACTS__MAKE_FRIEND);
}

	public void doContactsClass(HttpServletRequest request,HttpServletResponse 
			response,JsonElement je) throws SQLException {
		 ContactsListReceive contactlistrec = new Gson().fromJson(je,
				 ContactsListReceive.class);
	        getTelContactsControl().doHotContactsList(request,response,
	        		contactlistrec,getTelContactsControl().CONTACTS_CLASS);
}

	public void doHotContactsList(HttpServletRequest request,HttpServletResponse
			response,JsonElement je) throws SQLException {
		 ContactsListReceive contactlistrec = new Gson().fromJson(je,
				 ContactsListReceive.class);
        getTelContactsControl().doHotContactsList(request,response,
        		contactlistrec,getTelContactsControl().HOT_CONTACTS_LIST);


	}
	
	public void doIndexPicQuery(HttpServletRequest request,
			HttpServletResponse response, JsonElement je) throws SQLException {

		IndexPicQueryReceive indexpicquery=new Gson().fromJson(je, IndexPicQueryReceive.class);
	    getIndexPicControl().doIndexPicQuery(request,response,indexpicquery);	
	}
	 

	public void doLogin(HttpServletRequest request,
			HttpServletResponse response, JsonElement je) throws SQLException {
		L.p(T+"doLogin");
		LoginReceive login = new  Gson().fromJson(je, LoginReceive.class);
		LoginControl logincontrol = new LoginControl();
		
		logincontrol.doLogin(request,response,login);
	}
	public void doRegister(HttpServletRequest request,
			HttpServletResponse response, JsonElement je) throws SQLException {
		final String M="doRegister**********>";
		L.p(T+M);
		RegisterReceive register = new Gson().fromJson(je,RegisterReceive.class);
		RegisterControl registercontrol = new RegisterControl();
		registercontrol.doRegister(request,response,register);
	}
	public void doFeedBack(HttpServletRequest request,
			HttpServletResponse response, JsonElement je) throws SQLException {
		final String M="doFeedBack**********>";
		L.p(T+M);
		FeedBackReceive feedback = new Gson().fromJson(je,FeedBackReceive.class);
		FeedBackControl feedbackcontrol = new FeedBackControl();
		feedbackcontrol.doFeedBack(request, response, feedback);
	}
	public void doUpdateHeadImage(HttpServletRequest request,
			HttpServletResponse response, JsonElement je) {
		final String M="doUpdateHeadImage**********>";
		L.p(T+M);
		UpdateHeadImageReceive updateheadimage = new Gson().fromJson(je, 
				UpdateHeadImageReceive.class);
		getUpdateUserControl().doUpdateHeadImage(request,response,updateheadimage);


	}
	public void doUpdateUserName(HttpServletRequest request,
			HttpServletResponse response, JsonElement je) {
		final String M="doUpdateUserName";
		L.p(T+M);
		UpdateUserNameReceive updateusername = new Gson().fromJson(je, 
				UpdateUserNameReceive.class);
		getUpdateUserControl().doUpdateUserName(request,response,updateusername);
	}
	public void doUpdateUserRealName(HttpServletRequest request,
			HttpServletResponse response, JsonElement je) {
		UpdateUserRealNameReceive updateuserrealname =new Gson().fromJson(
				je,UpdateUserRealNameReceive.class);
		getUpdateUserControl().updateUserRealName(request,response,
				updateuserrealname);
	}
	public void doUpdateUserSex(HttpServletRequest request,
			HttpServletResponse response, JsonElement je) {
         UpdateUserSexReceive updateusersex = new Gson().fromJson(je,
        		 UpdateUserSexReceive.class);
         getUpdateUserControl().updateUserSex(request, response,updateusersex);
          
	}
	public void doUpdateUserBirthday(HttpServletRequest request,
			HttpServletResponse response, JsonElement je) {
         UpdateUserBirthdayReceive updateuserbirthday = new Gson().
        		 fromJson(je,UpdateUserBirthdayReceive.class);
         getUpdateUserControl().updateUserBirthday(request,response,
        		 updateuserbirthday);
	}
	public void doUpdateUserEntranceTime(HttpServletRequest request,
			HttpServletResponse response, JsonElement je) {
         UpdateUserEntranceTimeReceive updateuserentrancetime = new Gson().
        		 fromJson(je,UpdateUserEntranceTimeReceive.class);
	     getUpdateUserControl().updateUserEntranceTime(request,response,
	    		 updateuserentrancetime);
	}
	public void doUpdateUserPassword(HttpServletRequest request,
			HttpServletResponse response, JsonElement je) {
      UpdateUserPasswordReceive updateuserpassword = new Gson().fromJson(je,
    		  UpdateUserPasswordReceive.class);
	  getUpdateUserControl().updateUserPassword(request,response,updateuserpassword);
	 }
	public void doUpdateUserQQ(HttpServletRequest request,
			HttpServletResponse response, JsonElement je) {
      UpdateUserQQReceive updateuserqq = new Gson().fromJson(je,
    		  UpdateUserQQReceive.class);
      getUpdateUserControl().updateUserQQ(request,response,updateuserqq);
	}
	public void doUpdateUserBaiDu(HttpServletRequest request,
			HttpServletResponse response, JsonElement je) {
       UpdateUserBaiDuReceive updateuserbaidu = new Gson().fromJson(je,
    		   UpdateUserBaiDuReceive.class);
       getUpdateUserControl().updateUserBaiDu(request,response,updateuserbaidu);
       
	}
	public void doUpdateUserSina(HttpServletRequest request,
			HttpServletResponse response, JsonElement je) {
      UpdateUserSinaReceive updateusersina = new Gson().fromJson(je,UpdateUserSinaReceive.class);
      getUpdateUserControl().updateUserSina(request,response,updateusersina);
	}
	public void doUpdateUserWechat(HttpServletRequest request,
			HttpServletResponse response, JsonElement je) {
		UpdateUserWechatReceive updateuserwechat = new Gson().fromJson(je,
				UpdateUserWechatReceive.class);
		getUpdateUserControl().updateUserWechat(request,response,updateuserwechat);
		
	}
	public void doUpdateUserClassName(HttpServletRequest request,
			HttpServletResponse response, JsonElement je) {
		UpdateUserClassNameReceive updateuserclassname = new Gson().fromJson(je,
				UpdateUserClassNameReceive.class);
		getUpdateUserControl().updateUserClassName(request,response,updateuserclassname);
		
	}
	public void doUpdateUserJob(HttpServletRequest request,
			HttpServletResponse response, JsonElement je) {
		UpdateUserJobReceive updateuserjob = new Gson().fromJson(je,
				UpdateUserJobReceive.class);
		getUpdateUserControl().updateUserJob(request,response,updateuserjob);
		
	}
	public void doUpdateUserDegress(HttpServletRequest request,
			HttpServletResponse response, JsonElement je) {
		UpdateUserDegressReceive updateuserdegress = new Gson().fromJson(je,
				UpdateUserDegressReceive.class);
		getUpdateUserControl().updateUserDegress(request,response,updateuserdegress);
	}
	public void doUpdateUserPoliticalStatus(HttpServletRequest request,
			HttpServletResponse response, JsonElement je) {
		UpdateUserPoliticalStatusReceive updateuserpolicalstatus = 
				new Gson().fromJson(je,UpdateUserPoliticalStatusReceive.class);
		getUpdateUserControl().updateUserPoliticalStatus(request,response,updateuserpolicalstatus);
		
	}
	public void doTeacherAddNotify(HttpServletRequest request,
			HttpServletResponse response, JsonElement je) {
		TeacherAddNotifyReceive teacheraddnotifyreceive = new Gson().fromJson(je,
				TeacherAddNotifyReceive.class);
		if(!getAuthorityControl().validateTeacherAddNotify(request,response,
				teacheraddnotifyreceive)){
			return;
		}
		getSchoolNotifyControl().addSchoolNotify(request, response,
				teacheraddnotifyreceive);
	}
	public void doSchoolNotifyList(HttpServletRequest request,
			HttpServletResponse response, JsonElement je) {
		SchoolNotifyListReceive schoolnotifyreceive = new Gson().fromJson(je,
				SchoolNotifyListReceive.class);
		getSchoolNotifyControl().querySchoolNotifyByPage(request, response,
				schoolnotifyreceive);
		
	}
	public void doSchoolNotifyListDetail(HttpServletRequest request,
			HttpServletResponse response, JsonElement je) {
		SchoolNotifyListDetailReceive schoolnotifyreceive = new Gson().fromJson(je,
				SchoolNotifyListDetailReceive.class);
		getSchoolNotifyControl().querySchoolNotifyById(request, response,
				schoolnotifyreceive);
	}
	public void doClassListQuery(HttpServletRequest request,
			HttpServletResponse response, JsonElement je) {
		ClassListReceive classlistreceive = new Gson().fromJson(je,
				ClassListReceive.class);
		getAClassControl().queryClassListByProfessional(request,response,classlistreceive);
	}
	public void doStudentListQuery(HttpServletRequest request,
			HttpServletResponse response, JsonElement je) {
		StudentListReceive studentlistreceive = new Gson().fromJson(je,
				StudentListReceive.class);
		getStudentControl().queryStudentListByClassCode(request, response, 
				studentlistreceive);
		 
	}
	public void doProfessionalListQuery(HttpServletRequest request,
			HttpServletResponse response, JsonElement je) {
		ProfessionalListReceive professionallistreceive = new Gson().fromJson(je,
				ProfessionalListReceive.class);
		getProfessionalControl().queryProfessionalListByDepartmentCode(
				request,response,professionallistreceive);
	}
	public void doDeleteSchoolNotify(HttpServletRequest request,
			HttpServletResponse response, JsonElement je) {
		DeleteSchoolNotifyReceive deleteschoolnotifyreceive = new Gson().fromJson(je,
				DeleteSchoolNotifyReceive.class);
		getSchoolNotifyControl().deleteSchoolNotify(request,response,
				deleteschoolnotifyreceive);
	}
	public void doMonitorAddClassNotify(HttpServletRequest request,
			HttpServletResponse response, JsonElement je) {
		
		MonitorAddNotifyReceive monitoraddnotifyreceive = new Gson().fromJson(je,
				MonitorAddNotifyReceive.class);
		if(!getAuthorityControl().validateMonitorAddNotify(request,response,
				monitoraddnotifyreceive)){
			getClassNotifyControl().doNoAuthority(request,response,
					monitoraddnotifyreceive);
			return;
		}
	    getClassNotifyControl().addClassNotify(request,response,monitoraddnotifyreceive);
	}
	public void doClassNotifyList(HttpServletRequest request,
			HttpServletResponse response, JsonElement je) {
		ClassNotifyListReceive classnotifyreceive = new Gson().fromJson(je,
	     ClassNotifyListReceive.class);
		getClassNotifyControl().queryClassNotifyByPage(request,response,
				classnotifyreceive);
	}
	public void doClassNotifyListDetail(HttpServletRequest request,
			HttpServletResponse response, JsonElement je) {
		ClassNotifyListDetailReceive classnotifydetailreceive = new Gson().fromJson(je,
				ClassNotifyListDetailReceive.class);
		getClassNotifyControl().queryClassNotifyDetail(request,response,
				classnotifydetailreceive);
		
	}
	public void doDeleteClassNotify(HttpServletRequest request,
			HttpServletResponse response, JsonElement je) {
		DeleteClassNotifyReceive deleteclassnotify = new Gson().fromJson(je,
				DeleteClassNotifyReceive.class);
		getClassNotifyControl().deleteClassNotify(request,response,
				deleteclassnotify);
		
	}

	public void doQuerySchoolList(HttpServletRequest request,
			HttpServletResponse response, JsonElement je) {
		SchoolListReceive schoollistreceive = new Gson().fromJson(je,
				SchoolListReceive.class);
		getSchoolControl().doQuerySchoolList(request,response,schoollistreceive);
	}

	public void doQueryDeparmentList(HttpServletRequest request,
			HttpServletResponse response, JsonElement je) {
		DepartmentListReceive departmentreceive = new Gson().fromJson(je,
				DepartmentListReceive.class);
		getDepartmentControl().doQueryDepartmentList(request,response,departmentreceive);
	}

	public void doQuerySchoolInfo(HttpServletRequest request,
			HttpServletResponse response, JsonElement je) {
		// TODO Auto-generated method stub
		QuerySchoolInfoByUserNumberReceive queryschoolinforeceive = new Gson()
		.fromJson(je, QuerySchoolInfoByUserNumberReceive.class);
		getStudentControl().doQuerySchoolInfoByUserNumber(request, response, queryschoolinforeceive);
	}

	public void doQuerySchoolCalendar(HttpServletRequest request,
			HttpServletResponse response, JsonElement je) {
		QuerySchoolCalendarReceive queryschoolCalendarreceive = new Gson()
		.fromJson(je, QuerySchoolCalendarReceive.class);
		getSchoolCalendarControl().doQuerySchoolCalendar(request, response,
				queryschoolCalendarreceive);
	}
	
	public void doQueryContactsList(HttpServletRequest request,
			HttpServletResponse response, JsonElement je) {
		// TODO Auto-generated method stub
		QueryContactsListReceive queryContactsListreceive = new Gson()
		.fromJson(je, QueryContactsListReceive.class);
		System.out.println("----->"+queryContactsListreceive.toString());
		getContactsListControl().doQueryContactsList(request, response, queryContactsListreceive);
	}


	public void doSchoolNotifyFirst(HttpServletRequest request,
			HttpServletResponse response, JsonElement je) {
		// TODO Auto-generated method stub
		SchoolNotifyFirstReceive schoolnotifyfirst = new Gson().fromJson(je,SchoolNotifyFirstReceive.class);
	    getSchoolNotifyControl().doSchoolNotifyFirst(request,response,schoolnotifyfirst);
	}

	public void doClassNotifyFrist(HttpServletRequest request,
			HttpServletResponse response, JsonElement je) {
		// TODO Auto-generated method stub
		ClassNotifyFirstReceive classnotifyfirst = new Gson().fromJson(je, ClassNotifyFirstReceive.class);
	   getClassNotifyControl().doClassNotifyFirst(request,response,classnotifyfirst);   
	}

}
